# Contributor: Jean-Louis Fuchs <jean-louis.fuchs@adfinis-sygroup.ch>
# Contributor: omni <omni+alpine@hack.org>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=unison
pkgver=2.53.7
pkgrel=0
# Note: unison breaks compatibility between minor (major.minor) versions.
_majorver=${pkgver%.*}  # x.y
pkgdesc="Efficient file-synchronization tool"
url="https://www.cis.upenn.edu/~bcpierce/unison/"
arch="all"
license="GPL-3.0-or-later"
makedepends="ocaml linux-headers"
checkdepends="coreutils"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/bcpierce00/unison/archive/v$pkgver.tar.gz"

case "$CARCH" in
	riscv64|loongarch64)
		makedepends="${makedepends//ocaml/ocaml5}"
		;;
esac

build() {
	make NATIVE="$(command -v ocamlopt >/dev/null && echo true || echo false)"

	cp -v src/unison unison-text
	cp -v src/unison-fsmonitor unison-fsmonitor
}

check() {
	make test
}

package() {
	install -Dvm755 unison-text \
		"$pkgdir"/usr/bin/unison-text-$_majorver
	install -Dvm755 unison-fsmonitor \
		"$pkgdir"/usr/bin/unison-fsmonitor-$_majorver
	install -Dvm644 man/unison.1 \
		-t "$pkgdir"/usr/share/man/man1/

	cd "$pkgdir"/usr/bin
	ln -sv unison-text-$_majorver unison-text
	ln -sv unison-text unison
}

sha512sums="
11bd1d2792fb84fa2b29426516d7b91a2295febcb84052118d492a29d9ddaa23265b66cc88113019ec6782f3edcf596f7a37c8637e673b2928188248b9d63d60  unison-2.53.7.tar.gz
"
